import {createAction, createThunkAction} from "../../lib/redux-utils";
import {get, postJson} from "../../lib/http";
import {getPrincipal} from "../../lib/identity";

const principal = getPrincipal();
export const showCreate = createAction("ROLE.SHOW_CREATE");
export const hideCreate = createAction("ROLE.HIDE_CREATE");
export const showModify = createAction("ROLE.SHOW_MODIFY");
export const hideModify = createAction("ROLE.HIDE_MODIFY");
export const updateModel = createAction("ROLE.UPDATE");
export const copyModel = createAction("ROLE.COPY");

export const query = createThunkAction("ROLE.QUERY", () =>
    get("/role/all")
);
export const modify = createThunkAction("ROLE.MODIFY", params =>
    postJson("/role/update", params)
);
export const create = createThunkAction("ROLE.CREATE", params =>
    postJson("/role/create", params)
);
export const del = createThunkAction("", params =>
    get("/role/delete/" + params + "/" + principal.id)
);

